<template>
  <view :style="themeColor">
    <view class="page">
      <!---flex布局flex布局开始-->
      <view class="flex flex-wrap align-center justify-center benben-flex-layout bindPhone_flex_0">
        <image class='bindPhone_fd0_0' mode="aspectFit" :src='STATIC_URL+"22.png"'></image>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindPhone_flex_1">
        <view class='flex flex-wrap align-center bindPhone_fd1_0'>
          <image class='bindPhone_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"23.png"'></image>
          <input class='flex-sub bindPhone_fd1_0_c1' type="number" :placeholder="$t('请输入手机号')" confirm-type="done"
            :maxlength="20" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx"
            v-model="dataObj.actount" />
        </view>
        <view class='flex flex-wrap align-center bindPhone_fd1_0'>
          <image class='bindPhone_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"28.png"'></image>
          <input class='flex-sub bindPhone_fd1_0_c1' type="number" :placeholder="$t('请输入验证码')" confirm-type="done"
            :maxlength="4" placeholder-style="color:rgba(102, 102, 102, 1);font-size:28rpx" v-model="code" />
          <benben-send-verification-code ref="vCode1702822254564" class=' bindPhone_fd1_1_c2' :after-text="$t('后重新获取')"
            :before-text="$t('获取验证码')" :emptye-text="$t('请输入账号')" :validate-text="$t('请输入正确账号')" account-type='phone'
            :auto='true' type='5' :phone="dataObj.actount"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center bindPhone_fd1_0'>
          <image class='bindPhone_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"24.png"'></image>
          <benben-flex-password-diy v-model="dataObj.paswarld" class-name="flex flex align-center bindPhone_fd1_2_c1"
            :placeholder="$t('请输入密码(6~12位字母+数字)')" :maxlength="12" :default-type='true'
            placeholder-style="color:#999;font-size:28rpx">
            <template #show>
              <text class='fu-iconfont2  bindPhone_fd1_2_c1_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  bindPhone_fd1_2_c1_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
        <view class='flex flex-wrap align-center justify-center bindPhone_fd1_3' @click.stop="bindPhineFunc">
          <button class='bindPhone_fd1_3_c0'>{{$t('确定')}}</button>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "tabls": "1",
        "dataObj": {
          "actount": "",
          "mail": "",
          "paswarld": "",
          "is_tick": false
        },
        "code": "",
        "data": {
          "userinfo": {
            "user_token": "",
            "id": "",
            "avatar": "",
            "real_name": "",
            "nickname": "",
            "email": "",
            "gender": "",
            "mobile": "",
            "birthday": "",
            "client_id": "",
            "phone": ""
          }
        },
        bandInfo: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      let {
        client_id,
        third_type,
        bandInfo
      } = options
      if (client_id !== undefined) this.client_id = client_id
      if (third_type !== undefined) this.third_type = third_type
      if (bandInfo !== undefined) this.bandInfo = bandInfo
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //绑定手机号
      async bindPhineFunc() {
        if (!validate(this.dataObj.actount, 'require')) {
          this.$message.info(global.i18n.t('手机号不能为空'));
          return false;
        }
        // if (!validate(this.dataObj.actount, 'phone')) {
        //   this.$message.info(global.i18n.t('请输入正确的手机号'));
        //   return false;
        // }
        if (!validate(this.code, 'require')) {
          this.$message.info(global.i18n.t('验证码不能为空'));
          return false;
        }
        if (!validate(this.code, 'captcha')) {
          this.$message.info(global.i18n.t('请输入正确的验证码'));
          return false;
        }
        if (!validate(this.dataObj.paswarld, 'require')) {
          this.$message.info(global.i18n.t('密码不能为空'));
          return false;
        }
        if (!validate(this.dataObj.paswarld, 'password')) {
          this.$message.info(global.i18n.t('请输入密码(6~12位字母+数字)'));
          return false;
        }
        //请求方法
        //数据验证

        let datadata = await this.$api.post(global.apiUrls.post5d7757d28d076, {
          account: this.dataObj.actount,
          code: this.code,
          code_type: '5',
          account_type: 'mobile',
          third_type: 'wx_app',
          extend_info: this.bandInfo
        });

        if (datadata.data.code != 1) {
          this.$message.info(datadata.data.msg);
          return
        }
        let infodata = datadata.data;
        this.data = infodata.data
        this.$store.commit('saveToken', this.data.userinfo.user_token)
        this.$store.commit('updateUserInfo', this.data.userinfo)
        this.$message.info(global.i18n.t('绑定成功'));
        setTimeout(() => {
          this.toHomeDiy();
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('21.png')) no-repeat, #F7F3ED;
    background-size: 100% auto;
  }

  .bindPhone_flex_0 {
    padding: 105rpx 0rpx 0rpx 0rpx;
  }

  .bindPhone_fd0_0 {
    width: 136rpx;
    height: 141rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .bindPhone_flex_1 {
    padding: 0rpx 64rpx 0rpx 64rpx;
    margin: 74rpx 0rpx 0rpx 0rpx;
  }

  .bindPhone_fd1_3_c0 {
    background: rgba(145, 47, 34, 1);
    border-radius: 44rpx;
    width: 616rpx;
    line-height: 88rpx;
    font-size: 32rpx;
    color: #fff;
  }

  .bindPhone_fd1_3 {
    margin: 80rpx 0rpx 0rpx 0rpx;
  }

  .bindPhone_fd1_2_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .bindPhone_fd1_2_c1_icon1 {
    text-align: center;
    font-size: 40rpx;
  }

  ::v-deep .bindPhone_fd1_2_c1 {
    width: 543rpx;
    font-size: 28rpx;
    height: 32rpx;
    color: #333;
  }

  .bindPhone_fd1_1_c2 {
    line-height: 42rpx;
    text-align: center;
    font-size: 27rpx;
    color: rgba(51, 51, 51, 1);
  }

  .bindPhone_fd1_0_c1 {
    font-size: 28rpx;
    color: #333;
  }

  .bindPhone_fd1_0_c0 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 32rpx 0rpx 0rpx;
  }

  .bindPhone_fd1_0 {
    border-bottom: 1px solid rgba(232, 229, 216, 1);
    padding: 32rpx 0rpx 32rpx 0rpx;
  }
</style>